package propertydemo.propertydemo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import propertydemo.propertydemo.property.Market;
import propertydemo.propertydemo.property.Users;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author: liujinsheng
 * @Date: 2021/7/17.
 */
@RestController
//外部文件配置的属性
@EnableConfigurationProperties({Users.class})
public class Controller {
     @Value("${person.lastname}")
     String lastname;
     @Value("${user.name}")
     String username;
    @Value("${user.txt}")
    String txt;
    @Value("${user.number}")
    int number;
    @Value("${user.numberin}")
    int numberin;
    @Value("${user.long}")
    Long longstr;
    @Value("${user.uuids}")
    String uuid;
  @Value("${shuzu.list}")
  List list;
  @Resource
  Users users;
  @Resource
  Market market;

    @PostMapping("/getProperty")

    public String property(){
         System.out.println("从配置文件获取"+lastname);
        System.out.println("用$获取"+username);
        System.out.println("随机获取的文本"+txt);
        System.out.println("随机生成的数字"+number);
        System.out.println("随机生成10以内的数字"+numberin);
        System.out.println("随机生成long的数字"+longstr);
        System.out.println("随机生成uuid"+uuid);
        System.out.println("list"+list);

        System.out.println("从外部属性配置文件获取的对象"+users);
     return    lastname;

    }



}
